package com.kiven.swing;

import java.util.concurrent.TimeUnit;

import javax.swing.*;

public class SubmitSwingProgram extends JFrame {
	JLabel label;
	public SubmitSwingProgram() {
		super("Hello Swing");
		label = new JLabel("A Label");
		this.add(label);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setSize(500, 400);
		this.setVisible(true);
		System.out.println("this is constructor tip....");
	}
	
	static SubmitSwingProgram ssp;
	
	public static void main(String[] args) throws Exception {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				System.out.println("It is ready to construct Obj");
				ssp = new SubmitSwingProgram();
				System.out.println("sleep thread start......");
				try {
					TimeUnit.SECONDS.sleep(2);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println("sleep thread stop......");
			}
		});
		
		
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				System.out.println("This is another Label start...");
				ssp.label.setText("This is another text!");
				System.out.println("This is another Label stop...");
			}
		});
	}

}
